<template>
    <div>
         <input type="text" v-model="txt">
          <ul>
             <li v-for="(item,index) in list" :key="index">{{item}}</li>
          </ul>
    </div>
</template>
<script>
export default {
    data(){
        return{
          txt:'',
          list:['宝马','奔驰','苹果','香蕉','兰博基尼','本田','奥迪','奥拓'],
          arr:[],
          arrNew:[]  

        }
    },
    watch:{
      txt:function(newtxt,oldtxt){
    
        var qwe=[]
        if(!newtxt){
            this.list=this.arrNew
        }
        this.arrNew.forEach(it => {
          if(it.indexOf(newtxt)!=-1){ 
             qwe.push(it)
             this.list=qwe
          }
        });
      }                        
    },
    mounted(){
      this.arrNew=this.list.slice(0)
    }

}
</script>